unless defined?(RediPress)
  raise "You can't load this file. Please load the redipress file instead."
end

module RediPress
  # A RuntimeError subclass for when a configuration is not available.
  #
  class ConfigurationNotAvailable < RuntimeError
    attr_reader :slug

    def initialize(slug)
      @slug = slug
    end

    def to_s
      "The configuration '#{@slug}' is not available."
    end
  end

  # A RuntimeError subclass for when no configurations are available.
  #
  class NoConfigurationsAvailable < RuntimeError
    def to_s
      "There aren't any configurations available to use."
    end
  end

  # A NotImplementedError subclass for when the 'configure' method has not been implemented by a Configuration.
  #
  class ConfigurationNotImplemented < NotImplementedError
    def to_s
      "The 'configure' method has not been implemented by the configuration."
    end
  end

  # A RuntimeError subclass for when a configuration fails.
  #
  class ConfigurationFailed < RuntimeError
    attr_reader :configuration, :error

    def initialize(configuration, error)
      @configuration = configuration
      @error = error
    end

    def to_s
      "The configuration '#{@configuration.name}' failed: #{@error}"
    end
  end
end
